package cn.com.sparkle.paxos.net.netlayer.netty;

import io.netty.channel.ChannelHandlerContext;
import cn.com.sparkle.paxos.net.frame.FrameBody;
import cn.com.sparkle.paxos.net.netlayer.NetCloseException;
import cn.com.sparkle.paxos.net.netlayer.PaxosSession;

public class NettyPaxosSession extends PaxosSession {
	private ChannelHandlerContext ctx;

	public NettyPaxosSession(ChannelHandlerContext ctx) {
		this.ctx = ctx;
	}

	@Override
	public void write(FrameBody message) throws NetCloseException {
		ctx.writeAndFlush(message);
	}

	@Override
	public void closeSession() {
		ctx.close();
	}

}
